package dji.ux.ext.setting.gimbal;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import dji.sdk.gimbal.Gimbal;
import dji.sdk.sdkmanager.DJISDKManager;
import dji.ux.beta.R;
import dji.ux.beta.base.ConstraintLayoutWidget;

public class GimbalResetPanel extends ConstraintLayoutWidget {
    public GimbalResetPanel(@NonNull Context context) {
        super(context);
    }

    public GimbalResetPanel(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public GimbalResetPanel(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void initView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        View view = inflate(context, R.layout.ext_panel_gimbal_reset, this);
        TextView resetTV = view.findViewById(R.id.tv_gimbal_reset);
        resetTV.setOnClickListener((v) -> {
            if(DJISDKManager.getInstance().getProduct() != null){
                Gimbal gimbal = DJISDKManager.getInstance().getProduct().getGimbal();
                if(gimbal != null){
                    gimbal.reset(null);
                }
            }
        });
        setClickable(true);
        setFocusable(true);

        setBackgroundColor(Color.BLACK);
        setPadding(25, 25, 25, 25);
    }

    @Override
    protected void reactToModelChanges() {

    }

    @NonNull
    @Override
    public String getIdealDimensionRatioString() {
        return null;
    }
}
